/**
 * 
 */
package com.leolian.code.fragment.jdk8.lambda;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.function.Predicate;

/**
 * Description:
 * 
 * @author lianliang
 * @date 2018年4月13日 下午10:56:52
 */
public class LambdaPredicateDemo {
	public static List<String> filter(List<String> fruit, Predicate<String> predicate) {
		List<String> f = new ArrayList<>();
		for (String s : fruit) {
			if (predicate.test(s)) {
				f.add(s);
			}
		}
		return f;
	}

	public static void main(String[] args) {
		/*List<String> fruit = Arrays.asList("香蕉", "哈密瓜", "榴莲", "火龙果", "水蜜桃");
		List<String> newFruit = filter(fruit, (f) -> f.length() == 2);
		System.out.println(newFruit);*/
		
		List<Integer> list = Arrays.asList(2, 7, 3, 1, 8, 6, 4);
		list.sort(Comparator.naturalOrder());
		System.out.println(list);
	}
}
